<template>
	<view class="container">
		<view class="list">
			<view class="item">
				<p class="title">用户名 :</p>
				<input type="text" placeholer="用户名" v-model="dict.userName" />
			</view>
			<view class="item">
				<p class="title">性别 :</p>
				<input type="text" placeholer="性别" v-model="dict.sex" />
			</view>
			<view class="item">
				<p class="title">身份证 :</p>
				<input type="text" placeholer="身份证" v-model="dict.idcard" />
			</view>
			<view class="item">
				<p class="title">邮箱 :</p>
				<input type="text" placeholer="邮箱" v-model="dict.email" />
			</view>
			<view class="item">
				<p class="title">电话号码 :</p>
				<input type="text" placeholer="电话号码" v-model="dict.phonenumber" />
			</view>
			<button type="primary" @click="sendInfo()" style="width: 90%;margin:110px auto;">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		getUserInfo,
		editUserInfo
	} from "@/api/home.js"
	export default {
		data() {
			return {
				dict: {}
			}
		},
		onShow() {},
		mounted() {
			var that = this;
			getUserInfo({
				id: uni.getStorageSync("ownerId")
			}).then(res => {
				if (res.code == 200) {
					if (res.rows && res.rows.length > 0) {
						var dict = res.rows[0];
						that.dict = dict;

					}
				}
			}).catch(err => {
				// debugger
			})
		},
		watch: {},
		methods: {
			sendInfo() {
				editUserInfo({
					...this.dict
				}).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: "操作成功",
							icon: "none"
						})
					} else {
						uni.showToast({
							title: "操作失败",
							icon: "none"
						})
					}
				}).catch(err => {
					uni.showToast({
						title: "操作失败",
						icon: "none"
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.title {
		padding: 5px 15px;
		background: #e5e5e5;
		font-size: 15px;
		line-height: 30px;
	}

	input {
		padding: 10px 25px;
		border-bottom: 1px solid #ccc;
		background-color: #fff !important;
	}
</style>